![]() |
Kinetis SDK API Reference Manual
1.0.0-beta
Freescale Semiconductor, Inc.
|
The section describes the programming interface of the DMA Peripheral driver. More...
Data Structures | |
| struct | dma_channel_t |
| Data structure for the DMA channel management. More... | |
Typedefs | |
| typedef void(* | dma_callback_t )(void *parameter, dma_channel_status_t status) |
| A definition for the DMA channel callback function. More... | |
Enumerations | |
| enum | dma_channel_status_t { kDmaIdle, kDmaNormal, kDmaError } |
| Channel status for DMA channel. More... | |
| enum | dma_transfer_type_t { kDmaPeripheralToMemory, kDmaMemoryToPeripheral, kDmaMemoryToMemory, kDmaPeripheralToPeripheral } |
| Type for DMA transfer. More... | |
| enum | dma_channel_type_t { kDmaInvalidChannel = 0xFFU, kDmaAnyChannel = 0xFEU } |
| Type for the DMA channel, which is used for the DMA channel allocation. More... | |
DMA Driver | |
| dma_status_t | dma_init (void) |
| Initializes the DMA. | |
| dma_status_t | dma_deinit (void) |
| De-initializes the DMA. | |
| dma_status_t | dma_register_callback (dma_channel_t *chn, dma_callback_t callback, void *para) |
| Registers the callback function and a parameter. More... | |
| uint32_t | dma_get_descriptor_status (dma_channel_t *chn) |
| Gets the status of the EDMA channel descriptor chain. More... | |
| uint32_t | dma_request_channel (uint32_t channel, dma_request_source_t source, dma_channel_t *chn) |
| Requests a DMA channel. More... | |
| dma_status_t | dma_free_channel (dma_channel_t *chn) |
| Frees DMA channel hardware and software resource. More... | |
| dma_status_t | dma_start_channel (dma_channel_t *chn) |
| Starts a DMA channel. More... | |
| dma_status_t | dma_stop_channel (dma_channel_t *chn) |
| Stops a DMA channel. More... | |
| dma_status_t | dma_config_transfer (dma_channel_t *chn, dma_transfer_type_t type, uint32_t size, uint32_t sourceAddr, uint32_t destAddr, uint32_t length) |
| Configures a transfer for the DMA. More... | |
| void | dma_IRQhandler (uint32_t channel) |
| DMA IRQ handler for both an interrupt and an error. More... | |
| struct dma_channel_t |
Data Fields | |
| uint8_t | channel |
| Channel number. | |
| uint8_t | dmamuxModule |
| Dmamux module index. | |
| uint8_t | dmamuxChannel |
| Dmamux module channel. | |
| dma_callback_t | callback |
| Callback function for this channel. | |
| void * | parameter |
| Parameter for the callback function. | |
| volatile dma_channel_status_t | status |
| Channel status. | |
| typedef void(* dma_callback_t)(void *parameter, dma_channel_status_t status) |
A prototype for the callback function registered into the DMA driver.
| enum dma_channel_status_t |
| enum dma_transfer_type_t |
| enum dma_channel_type_t |
| dma_status_t dma_register_callback | ( | dma_channel_t * | chn, |
| dma_callback_t | callback, | ||
| void * | para | ||
| ) |
The user registers the callback function and a parameter for a specified DMA channel. When the channel interrupt or a channel error happens, the callback and the parameter are called. The user parameter is also provided to give a channel status.
| chn | A handler for the DMA channel |
| callback | Callback function |
| para | A parameter for callback functions |
| uint32_t dma_get_descriptor_status | ( | dma_channel_t * | chn | ) |
Gets the left bytes to be transferred.
| chn | A handler for the DMA channel |
| uint32_t dma_request_channel | ( | uint32_t | channel, |
| dma_request_source_t | source, | ||
| dma_channel_t * | chn | ||
| ) |
This function provides two ways to allocate a DMA channel. The first way is a static allocation. The second way is a dynamic allocation. To allocate a channel dynamically, the user needs to set the channel parameter with the value of kDmaAnyChannel. The driver searches into all available free channels and assigns the first channel to the user. To allocate the channel statically, the user needs to set the channel parameter with the value of a specified channel. If the channel is available, the driver assigns the channel to the user. Notes: The user must provide a handler memory for the DMA channel. The driver initializes the handler and configures the handler memory.
| channel | A DMA channel number. If a channel is assigned with a valid channel number, the DMA driver tries to assign a specified channel to the user. If a channel is assigned with kDmaAnyChannel, the DMA driver searches all available channels and assigns the first channel to the user. |
| source | A DMA hardware request. |
| chan | Memory pointing to DMA channel. The user must ensure that the handler memory is valid and that it will not be released or changed by any other codes before the channel dma_free_channel() operation. |
| dma_status_t dma_free_channel | ( | dma_channel_t * | chn | ) |
This function frees the relevant software and hardware resources. Both the request and the free operations need to be called in a pair.
| chn | Memory pointing to DMA channel. |
| dma_status_t dma_start_channel | ( | dma_channel_t * | chn | ) |
Starts a DMA channel. The driver starts a DMA channel by enabling the DMA request. A software start bit is not used in the DMA Peripheral driver.
| chn | Memory pointing to the DMA channel. |
| dma_status_t dma_stop_channel | ( | dma_channel_t * | chn | ) |
| chn | Memory pointing to the DMA channel. |
| dma_status_t dma_config_transfer | ( | dma_channel_t * | chn, |
| dma_transfer_type_t | type, | ||
| uint32_t | size, | ||
| uint32_t | sourceAddr, | ||
| uint32_t | destAddr, | ||
| uint32_t | length | ||
| ) |
Configures a transfer for the DMA.
| chn | Memory pointing to the DMA channel. |
| type | Transfer type. |
| size | Size to be transferred on each DMA write/read. Source/Dest share the same write/read size. |
| sourceAddr | Source address. |
| destAddr | Destination address. |
| length | Bytes to be transferred. |
| void dma_IRQhandler | ( | uint32_t | channel | ) |
| channel | DMA channel number. |